package com.coursehub.shared.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 服务配置属性
 */
@Data
@Component
@ConfigurationProperties(prefix = "coursehub.services")
public class ServiceProperties {
    
    /**
     * 服务URL映射
     */
    private Map<String, String> urls = new HashMap<>();
    
    /**
     * 获取服务URL
     */
    public String getServiceUrl(String serviceName) {
        return urls.get(serviceName);
    }
    
    /**
     * 用户管理服务URL
     */
    public String getUserServiceUrl() {
        return urls.getOrDefault("user-management", "http://localhost:8082");
    }
    
    /**
     * 课程管理服务URL
     */
    public String getCourseServiceUrl() {
        return urls.getOrDefault("course-management", "http://localhost:8083");
    }
    
    /**
     * 练习管理服务URL
     */
    public String getExerciseServiceUrl() {
        return urls.getOrDefault("exercise-management", "http://localhost:8084");
    }
    
    /**
     * 学习进度服务URL
     */
    public String getProgressServiceUrl() {
        return urls.getOrDefault("learning-progress", "http://localhost:8085");
    }
}